//go:build darwin || (linux && amd64)

package osx

import (
	"os"
	"syscall"
)

func RedirectStdoutStdErr(filename string) {
	redirectFile, err := os.OpenFile(filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
	if err != nil {
		panic(err)
	}
	if err = syscall.Dup2(int(redirectFile.Fd()), int(os.Stdout.Fd())); err != nil {
		panic(err)
	}
	if err = syscall.Dup2(int(redirectFile.Fd()), int(os.Stderr.Fd())); err != nil {
		panic(err)
	}
}
